<?php
/**
 * 我的控制器包含（我的发布，我的关注， 我的收藏， 我的账单）
 */

namespace app\index\controller;

use app\common\exception\System as SystemException;
use Exception;

class Mine extends Common
{

//    protected $noNeedLogin = ['index','getMyLanded'];

    /**
     * @return \think\Response
     * 获取我的地产
     */
    public function getMyLanded()
    {
        $member_id = $this->auth->member_id;
//        $member_id = trim($this->request->post('member_id'));
        $list = service('index/Mine')->getMyLanded($member_id);
        return $this->successReturn($list, SystemException::E_SUCCESS, '修改成功');
    }


    /**
     * 申请店铺
     */
    public function applyShop()
    {
        $member_id = $this->auth->member_id;
        $applyShop = service('index/Landed')->getApplyShop($member_id);
        $businesscert = service('index/Setting')->getMemberBusinessCert($member_id);
        if(!$businesscert || $businesscert['is_verfiy'] != 1){
            return $this->errorReturn(SystemException::E_VALIDATE,'请先认证企业信息');
        }
        if($this->request->isPost()){
            $param['name'] = trim($this->request->post('name'));
            $param['phone'] = trim($this->request->post('phone'));
            $param['address'] = trim($this->request->post('address'));
            $param['is_vefiy'] = 0;
            $ret = service('index/Mine')->setApplyShop($member_id,$param);
            return $this->successReturn($ret,SystemException::E_SUCCESS, '获取成功');
        }
        return $this->successReturn($applyShop,SystemException::E_SUCCESS, '获取成功');
    }







}